﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcCmsWikiPlex
{
    public class Routes : AreaRegistration
    {
        public override string AreaName
        {
            get { return "MvcCmsWikiPlex"; }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            var routes = context.Routes;

            routes.MapRoute(
                "WikiManage",
                "wiki/manage",
                new { controller = "WikiPlex", action = "ManageWiki" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "WikiEditSettings",
                "wiki/editsettings",
                new { controller = "WikiPlex", action = "EditWikiSettings" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "WikiHistory",
                "wiki/{slug}/v{version}",
                new { controller = "WikiPlex", action = "ViewWikiVersion" },
                new { version = @"\d+" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "WikiSource",
                "wiki/{slug}/source/v{version}",
                new { controller = "WikiPlex", action = "GetWikiSource" },
                new { version = @"\d+" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "WikiAct",
                "wiki/{slug}/{action}",
                new { controller = "WikiPlex", action = "ViewWiki" },
                new { action = @"\w+" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "WikiDefault",
                "wiki/{slug}",
                new { controller = "WikiPlex", action = "ViewWiki", slug = "home" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "WikiAjax",
                "wikiajax/{action}/{id}/{slug}",
                new { controller = "WikiPlexAjax" }
                ).DataTokens = new RouteValueDictionary(new { area = AreaName });
        }
    }

}
